LinqConnect Documentation
Devart.Data.Linq Namespace / DataContext Class / ExecuteQuery Method / ExecuteQuery(Type,String,Object[]) Method
The type of the IEnumerable(T) to be returned.

The algorithm for matching columns in the result of the query to fields or properties in the object works as follows:

The query must return all the tracked fields and properties of the object (except those that are loaded on a deferred basis) when all the following conditions are true:

Otherwise an exception is thrown.

The SQL query to be executed.
The array of parameters to be passed to the command. Note the following behavior:

In This Topic
    ExecuteQuery(Type,String,Object[]) Method
    In This Topic
    Executes SQL queries directly on the database.
    Syntax
    'Declaration
     
    Public Overloads Function ExecuteQuery( _
       ByVal elementType As Type, _
       ByVal query As String, _
       ByVal ParamArray parameters() As Object _
    ) As IEnumerable
    public IEnumerable ExecuteQuery( 
       Type elementType,
       string query,
       params object[] parameters
    )

    Parameters

    elementType
    The type of the IEnumerable(T) to be returned.

    The algorithm for matching columns in the result of the query to fields or properties in the object works as follows:

    • If a field or property is mapped to a particular column name, that column name is expected in the resultset.
    • If a field or property is not mapped, a column with the same name as the field or property is expected in the resultset.
    • The comparison is performed by looking for a case-sensitive match first. If this match is not found, a subsequent search occurs for a case-insensitive match.

    The query must return all the tracked fields and properties of the object (except those that are loaded on a deferred basis) when all the following conditions are true:

    • T is an entity explicitly tracked by the DataContext.
    • ObjectTrackingEnabled is true.
    • The entity has a primary key.

    Otherwise an exception is thrown.

    query
    The SQL query to be executed.
    parameters
    The array of parameters to be passed to the command. Note the following behavior:
    • If the number of objects in the array is less than the highest number identified in the command string, an exception is thrown.
    • If the array contains objects that are not referenced in the command string, no exception is thrown.
    • If any one of the parameters is null, it is converted to DBNull.Value.

    Return Value

    An IEnumerable(T) collection of objects returned by the query.
    Requirements

    Target Platforms: Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

    See Also